const Events=require('yg-Events');

cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        console.log(1);
        this.node.on(cc.Node.EventType.TOUCH_MOVE,this.touch_move,this);
        this.node.on(cc.Node.EventType.TOUCH_END,this.touch_end,this);
        this.fire();
    },
    touch_move(e){
        let pos=this.node.parent.convertToNodeSpaceAR(e.getLocation());
        this.node.x=pos.x;
        this.node.y=pos.y;
    },
    touch_end(){

    },
    //射击
    fire(){
        this.unscheduleAllCallbacks();
        this.schedule(this._fire,1);
    },
    _fire(){
        Events.emit('myBullet',this.node.x,this.node.y,0,10,1,0);
    },
    //暴走射击
    superFire(){
        this.unscheduleAllCallbacks();
        this.schedule(this._superFire,0.1);
    },
    _superFire(){

    },
    stopFire(){
        this.unscheduleAllCallbacks();
    }
    // update (dt) {},
});
